package com.sismul;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class BandsSQLiteHelper extends SQLiteOpenHelper {

	public static final String TABLE_BANDS = "bands";
	public static final String COLUMN_ID = "id";
	public static final String COLUMN_BAND = "band";
	public static final String COLUMN_LEVEL = "level";
	
	private static final String DATABASE_NAME = "bands.db";
	
	private static final int DATABASE_VERSION = 1;

	// Database creation sql statement
	private static final String DATABASE_CREATE = "create table "
		+ TABLE_BANDS + "( " + COLUMN_ID
		+ " integer primary key, " + COLUMN_BAND
		+ " text not null, " + COLUMN_LEVEL
		+ " int default 0);";

	public BandsSQLiteHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.e(BandsSQLiteHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_BANDS);
		onCreate(db);
	}

}
